<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2022/3/11
 * Time: 9:30
 */

namespace app\api\validate;

use think\Validate;
class Message extends Validate
{
    public function checkMobile($mobile)
    {
        if(preg_match("/^1[34578]\d{9}$/", $mobile)){
            return true;
        }
        return false;
    }
    protected $rule = [
        'name'  => 'require',//|unique:User
        'mobile' => 'require|checkMobile',
        'content' => 'require',
    ];

    /**
     * 提示消息
     */
    protected $message = [
        'name.require' => '联系人不能为空',
        'mobile.unique' => '联系电话不能为空',
        'mobile.checkMobile' => '电话格式不正确',
        'content.require' => '留言内容不能为空',
    ];
}